<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改角色')" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form  th:object="${category}" action="/price/category/edit" method="post">
			<input type="hidden" th:field="*{id}" name="id"/>

			<div class="mb-3">
				<label class="form-label">地域名称</label>
				<input type="text" class="form-control" th:field="*{categoryName}" id="categoryName" name="categoryName">
			</div>

			<button type="submit"  class="btn btn-success">保存</button>
			<a href="/price/category/list" class="btn btn-secondary">取消</a>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: ztree-js" />
	<script type="text/javascript">
		function edit() {
			var id = $("input[name='id']").val();
			var categoryName = $("input[name='categoryName']").val();

			$.ajax({
				cache : true,
				type : "POST",
				url : ctx + "price/category/edit",
				data : {
					"id": id,
					"categoryName": categoryName
				},
				async : false,
				error : function(request) {
					$.modal.alertError("系统错误");
				},
				success : function(data) {
					var redirectUrl = "/price/category/list";
					console.log("======================>" + redirectUrl);
					window.location.replace = redirectUrl;
				}
			});
		}
		
		function submitHandler() {
	        edit();
	    }
		$("#saveBtn").click(function() {
			edit();
		});
	</script>
</body>
</html>
